package ai.people.core.information.api;

import ai.people.netmon.framework.domain.archives.dto.*;
import org.springframework.core.NamedThreadLocal;

/**
 * 信息搜索服务接口规范
 *
 * @author LiGuanNan
 * @date 2022/6/6 17:22
 */
public interface InformationStanderSearchService {

    /**
     * sid threadLocal
     */
    ThreadLocal<Long> SID_THREAD_LOCAL = new NamedThreadLocal<>("information search sid in threadLocal");

    /**
     * 获取信息源类型
     *
     * @return {@link Integer}
     */
    String getInformationSearchSource();

    /**
     * 当前数据源服务是否可用
     *
     * @return {@link Integer}
     */
    Boolean isEnable();

    /**
     * 信息检索
     * @param reqParam
     * @return
     */
    ThirdPartyCommonRespDTO<ThirdPartySearchPageResponse<ThirdPartyInformationSearchRespDTO>> search(InformationThirdPartySearchReqDTO reqParam);

    /**
     * 信息检索v2版本，会将检索结果记录到redis中
     * @param reqParam
     * @return
     */
    ThirdPartyCommonRespDTO<ThirdPartySearchPageResponse<ThirdPartyInformationSearchRespDTO>> searchV2(InformationThirdPartySearchReqDTO reqParam);

    /**
     * 查看详情
     * @param dataId
     * @return
     */
    ThirdPartyCommonRespDTO<ThirdPartyInformationDetailRespDTO> detail(String dataId);

    /**
     * 得到sid
     *
     * @return {@link Long}
     */
    default Long getSid(){
        return SID_THREAD_LOCAL.get();
    }

    /**
     * 设置sid
     *
     * @param sid sid
     */
    default void setSid(Long sid){
        SID_THREAD_LOCAL.set(sid);
    }

    /**
     * 删除sid
     */
    default void removeSid(){
        SID_THREAD_LOCAL.remove();
    }
}
